home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / vidbasic.zip / VPRINT.ASM < prev    next >
Assembly Source File  |  1990-11-29  |  11KB  |  283 lines

  1. ;«RM82»«TS8,16,24,32,40,48,56,64»
  2. ; Updated 11/20/90
  3.  
  4. ;============================================================================
  5. ;   Copyright (C) Copr. 1990 by Sidney J. Kelly
  6. ;           All Rights Reserved.
  7. ;           Sidney J. Kelly
  8. ;           150 Woodhaven Drive
  9. ;           Pittsburgh, PA 15228
  10. ;           home phone 412-561-0950 (7pm to 9:30pm EST)
  11. ;============================================================================
  12.  
  13. DOSSEG
  14. .model medium, Basic
  15. .data
  16.     ;external data so all video routines can access
  17.     EVEN
  18.     EXTRN    B$DVIDEOSEG:WORD
  19.     EXTRN   B$DVIDEOPORT:WORD
  20.     EXTRN   B$DVIDEODI:WORD
  21.     EXTRN   B$DVIDEOINSTL:BYTE
  22. .code
  23.  
  24. INCLUDE NOWAIT.INC
  25. EXTRN    Get_Adapter:FAR
  26. EXTRN    SET_DI:FAR
  27.  
  28. ;============================================================================
  29. ; QPRINT.ASM - performs Quick Printing in the QuickBASIC
  30. ; DECLARE SUB QPRINT (BYVAL ROW%, BYVAL COL%, Text$, BYVAL ATTRIBUTE%)
  31. ; Works in TextMode only, ignores all special characters
  32. ; Sensitive to all video modes (i.e. no snow on CGA's)
  33. ; If no attribute is selected, the default attribute is &h07 (normal)
  34. ; Assumes: Display width is 80 columns, Rows are 25, 43, or 50
  35. ;============================================================================
  36.  
  37. EVEN
  38. QPRINT Proc FAR BASIC USES SI DI, \
  39. ROW:Ptr, COLL:Ptr, TEXTSTRG:Ptr, ATTRIB:Ptr
  40.  
  41. comment |
  42.      Register usage when all done:
  43.      AH = Color attribute for printing entire string.
  44.      AL = temporarily holds the character to print.
  45.      CX = Length of Text string.
  46.      DX = Port for CGA video retrace check, if necessary.
  47.           0 means display is not a not a CGA display
  48.      DI = Offset of Screen for current character
  49.      ES = Segment of Video display, 0xB000 or 0xB800
  50.      SI = Offset of Text String
  51.      DS = Assumed to point to segment containing Text string.
  52.           Program does not set this, so string is assumed to
  53.           be a near string in DGROUP, the default in QB 4.5
  54.      BX = is used as a scratch variable register
  55.      |
  56.  
  57.     Assume    DS:@data
  58.  
  59.     Cmp   B$DVIDEOINSTL,1 ;See if we have done this before
  60.     JE    Didit        ;yep, so skip ahead
  61.     Call  Get_Adapter  ;call routine to find display type
  62.  
  63. Didit:
  64.     Mov   CX,ROW       ;read value of Row
  65.                ;   allow EGA 43 line/ VGA 50 line
  66.     Dec   CX           ;convert to BIOS format
  67.     Cmp   CX,49        ;check if within range 1 to 50
  68.     JA    Exit         ;exit if too large, or 0
  69.     Mov   DH,CL        ;store ROW (CL) in DH
  70.  
  71.     Mov   CX,COLL      ;read value of COLL
  72.     Dec   CX           ;convert to BIOS format
  73.     Cmp   CX,79        ;check if within range 1 to 80
  74.     JA    Exit         ;exit if too large, or 0
  75.     Mov   DL,CL        ;store COLL (CL) in DL
  76.     CALL SET_DI        ;call routin to find video seg offset in DI
  77.       
  78.     Mov   ES,B$DVIDEOSEG  ;restore the initialized values
  79.     Mov   DX,B$DVIDEOPORT ;puts 0 in DX if not CGA
  80.     Mov   AX,ATTRIB    ;get the color ATTRIBUTE% that was passed
  81.     Mov   AH,AL        ;put it into AH for screen writing below
  82.     Or    AH,AH        ;& make sure attribute is not &H00
  83.     Jnz   @f           ;this is the default if no attribute selected
  84.     Mov   AH,07        ;Default of black background, white letters
  85. @@:
  86.     Mov   SI,TEXTSTRG  ;put descriptor to TEXT$ into SI
  87.     Mov   CX,[SI]      ;put Len(TEXT$) into CX for loop counter
  88.     JCXZ  Exit         ;if CX is zero it's a null string, exit now
  89.     Mov   SI,[SI+02]   ;put address of first character in X$ into SI
  90.     Cld                ;clear the direction flag to move data forward
  91.  
  92. Main_Loop:
  93.     Or    DX,DX        ;are we on a mono or EGA system (is DX = 0)?
  94.     JZ    Mono         ;yes, skip over the retrace stuff
  95.  
  96. EVEN
  97. CGA:
  98.     CLI                ;prevent interrupts to speed routine
  99.     Wait_CGA_Retrace   ;wait for CGA retrace MACRO
  100.     Lodsb              ;get the character from TEXT$ and increment SI
  101.     Stosw              ;store both the character and attribute
  102.     STI                ;allow interrupts again
  103.     Loop  CGA          ;loop until CX is zero
  104.     Jmp  Short  Exit
  105. EVEN
  106. Mono:
  107.     Lodsb              ;get the character from TEXT$ and increment SI
  108.     Stosw              ;store both the character and attribute
  109.     Loop  Mono         ;loop until CX is zero
  110.  
  111. Exit:
  112.     Mov   B$DVIDEODI,DI ;save current DI
  113.     Ret                ;return skipping the passed parameters
  114. QPRINT  Endp
  115.  
  116. ;============================================================================
  117. ; QPRT.ASM - performs Quick Printing in the QuickBASIC
  118. ; DECLARE SUB QPRT (BYVAL ROW%, BYVAL COL%, TEXT$)
  119. ; Works in TextMode only, ignores all special characters
  120. ; Sensitive to all video modes (i.e. no snow on CGA's)
  121. ; Does not change the attribute, uses whatever was there.
  122. ; Much faster than LOCATE X,Y : PRINT T$
  123. ; Routine is about 6   times faster than PRINT on a color EGA on an AT
  124. ;            about 4.5 times faster than PRINT on a color VGA on a AT-SX
  125. ;            about 7   times faster than PRINT on a mono EGA on an AT
  126. ;            about 2   times faster than PRINT on a CGA on an IBM PC
  127. ;            about 5   times faster than PRINT on a HERC on an AT
  128. ;            about 6   times faster than PRINT on a COMPAQ Portable
  129. ;
  130. ; Assumes: Display width is 80 columns, Max Rows are 25, 43, or 50
  131. ;============================================================================
  132.  
  133. EVEN
  134. QPRT Proc FAR BASIC USES SI DI, \
  135. ROW:Ptr, COLL:Ptr, TEXTSTRG:Ptr,
  136.  
  137.         Assume    DS:@data
  138.  
  139.     Cmp   B$DVIDEOINSTL,1 ;See if we have done this before
  140.     JE    Didit1       ;yep, so skip ahead
  141.     Call  Get_Adapter  ;call routine to find display type
  142.  
  143. Didit1:
  144.     Mov   CX,ROW       ;read value of ROW
  145.                ;--allow EGA 43 line/ VGA 50 line
  146.     Dec   CX           ;convert to BIOS format, 0 wd become &HFFFF
  147.     Cmp   CX,49        ;check if within range 1 to 50
  148.     JA    Exit1        ;exit if too large
  149.     Mov   DH,CL        ;store CL in DH
  150.  
  151.     Mov   CX,COLL      ;read value of COLL
  152.     Dec   CX           ;convert to BIOS format, a 0 wd become &HFFFF
  153.     Cmp   CX,79        ;check if within range 1 to 80,
  154.     JA    Exit1        ;exit if too large, exit if >80 or = 0
  155.     Mov   DL,CL        ;store CL in DL
  156.  
  157.     CALL SET_DI        ;call routine to find video seg offset in DI
  158.  
  159.     Mov   ES,B$DVIDEOSEG  ;restore the initialized values
  160.     Mov   DX,B$DVIDEOPORT ;DX = 0 if not CGA, else CGA retrace port
  161.  
  162.     Mov   SI,TEXTSTRG  ;put descriptor to TEXT$ into SI
  163.     Mov   CX,[SI]      ;put Len(TEXT$) into CX for loop counter
  164.     JCXZ  Exit1        ;if CX is zero it's a null string, exit now
  165.     Mov   SI,[SI+02]   ;put address of first character in X$ into SI
  166.     Cld                ;clear the direction flag to move data forward
  167.  
  168. Main_Loop1:
  169.     OR    DX,DX        ;are we on a mono or EGA system (is DX = 0)?
  170.     JZ    Mono1        ;yes, skip over the retrace stuff
  171.  
  172. EVEN               ; speeds loop
  173. CGA1:
  174.     CLI                ;prevent interrupts to speed routine
  175.     Wait_CGA_Retrace   ;wait for CGA retrace MACRO
  176.     Lodsb              ;get the character from TEXT$ and increment SI
  177.     Stosb              ;store just the character but not the attribute
  178.     STI                ;allow interrupts again
  179.     Inc    DI          ;skip to next cell
  180.     Loop   CGA1        ;loop until CX is zero
  181.     Jmp   Short  Exit1
  182.  
  183. EVEN               ; speeds loop
  184. Mono1:
  185.     Lodsb              ;get the character from TEXT$ and increment SI
  186.     Stosb              ;store just the character but not the attribute
  187.     Inc    DI          ;skip to next cell
  188.     Loop   Mono1       ;loop until CX is zero
  189.  
  190. Exit1:
  191.     Mov  B$DVIDEODI,DI ;save current DI
  192.     Ret                ;return skipping the passed parameters
  193. QPRT    Endp
  194.  
  195. ;============================================================================
  196. ; DECLARE SUB QATTRIB (BYVAL ROW%, BYVAL COL%, BYVAL NUMCHAR%, BYVAL ATTRIB%)
  197. ; CALL QATTRIB(ROW%, COL%, NUMCHAR%, ATTRIB%)
  198. ; Row, Column is the starting location. attribute is the color
  199. ; and Numchar is the number of characters to change.
  200. ; Changes the attribute of characters on the screen in text mode
  201. ; Assumes: Display width is 80 columns, Rows are 25, 43, or 50
  202. ;============================================================================
  203.  
  204. EVEN
  205. QATTRIB Proc FAR BASIC USES SI DI, \
  206. ROW:Ptr, COLL:Ptr, NUMCHAR:Ptr, ATTRIB:Pt